<?php

namespace app\backend\controller;

use app\common\controller\Basic;
use app\common\service\crm\ClueService;
use app\common\service\crm\ContractService;
use app\common\service\crm\ProductTypeService;
use app\common\service\hrm\CompanyService;
use app\common\service\hrm\DeptService;
use app\common\service\hrm\RankingService;
use app\common\service\sys\DictService;
use app\common\service\sys\UserGroupService;
use app\common\service\sys\UserService;
use app\common\service\xzm\CarService;
use app\common\service\sys\UserGroupMemberService;
use app\common\service\hrm\CheckrulesService;
use app\common\service\hrm\RestrulesService;
use app\common\service\pmm\AuditGroupService;
use app\common\service\crm\CustomerService;
use app\common\service\crm\ContactsService;
use app\common\service\crm\ProductService;
use app\common\service\crm\ProductPartService;

/**
 * 弹出选择窗集聚在此控制器
 * @author kaige
 * @date 2022-04-29
 */
class Select extends Basic
{

    //选择单位
    public function company()
    {
        if ($this->request->isGet()) {
            return json((new CompanyService())->_list(input('param.')));
        }
        return _jerr(1000);
    }

    /**相关文件*/
    // public function files()
    // {
    //     if($this->request->isGet())
    //     {
    //         return (new HrmFilesServer())->getItems(input('id/d',0));
    //     }
    //     return _jerr(1000);
    // }

    //选择员工
    public function employee()
    {
        if ($this->request->isGet()) {
            return json((new UserService())->_list(input('param.')));
        }
        return _jerr(1000);
    }

    //选择职位
    public function ranking()
    {
        if ($this->request->isGet()) {
            return (new RankingService())->_list(input('param.'));
        }
        return _jerr(1000);
    }

    //选择部门
    public function dept()
    {
        if ($this->request->isGet()) {
            return (new DeptService())->_list(input('param.'), false);
        }
        return _jerr(1000);
    }

    //选择字典
    public function dict()
    {
        if ($this->request->isGet()) {
            return json((new DictService())->_list(input('param.'), false));
        }
        return _jerr(1000);
    }

    // 选择用户分组
    public function usergroup()
    {
        if ($this->request->isGet()) {
            return json((new UserGroupService())->_list(input('param.'), false));
        }
        return _jerr(1000);
    }

    // 选择用户分组
    public function usergroupdept()
    {
        if ($this->request->isGet()) {
            return json([
                'group' => (new UserGroupService())->getUserGroupLayuiTree(),
                'dept' => (new DeptService())->getDeptLayuiTree()
            ]);
        }
        return _jerr(1000);
    }

    // 选择分组用户
    public function usergrouplist()
    {
        if ($this->request->isGet()) {
            $group_id = input('group_id/d', 0);
            return json((new UserGroupMemberService())->getUserByGroup($group_id));
        }
        return _jerr(1000);


    }

    //选择车牌号
    public function licenseplatenumber()
    {
        if ($this->request->isGet()) {
            return json((new CarService())->_list(input('param.')));
        }
        return _jerr(1000);
    }

    //获取考勤规格名称
    public function checkrules()
    {
        if ($this->request->isGet()) {
            return (new CheckrulesService())->_list(input('param.'), false);
        }
        return _jerr(1000);
    }

    //审核人员分组
    public function auditgroup()
    {
        if ($this->request->isGet()) {
            return (new AuditGroupService())->getauditgroup();
        }
        return _jerr(1000);
    }

    //获取休息规格名称
    public function restRules()
    {
        if ($this->request->isGet()) {
            return (new RestrulesService())->_list(input('param.'), false);
        }
        return _jerr(1000);
    }

    //获取产品类型
    public function productType()
    {
        if ($this->request->isGet()) {
            return (new ProductTypeService())->_list(input('param.'), false);
        }
        return _jerr(1000);
    }


    //获取现索名称
    public function ClueName()
    {
        if ($this->request->isGet()) {
            return (new ClueService())->_list(input('param.'), false);
        }
        return _jerr(1000);
    }

    //获取客户
    public function Customer()
    {
        if ($this->request->isGet()) {
            $data = input('param.');
            $data['type'] = 0;
            return (new CustomerService())->_list($data, false);
        }
        return _jerr(1000);
    }

    //获取联系人
    public function Contacts()
    {
        if ($this->request->isGet()) {

            $data = input('param.');
            return (new ContactsService())->_list($data, false);
        }
        return _jerr(1000);
    }

    //获取产品
    public function Product()
    {
        if ($this->request->isGet()) {

            $data = input('param.');
            return (new ProductService())->_list($data, false);
        }
        return _jerr(1000);
    }

    //获取产品配件
    public function ProductPart()
    {
        if ($this->request->isGet()) {

            $data = input('param.');
            return (new ProductPartService())->_list($data, false);
        }
        return _jerr(1000);
    }

    public function Contract()
    {
        if ($this->request->isGet()) {
            $data = input('param.');
            return (new ContractService())->_list($data, false);
        }
        return _jerr(1000);
    }


}
